{$layout}

{$template "node_menu"}

<h3>节点详情</h3>
<table class="ui table definition selectable">
    <tr>
        <td class="title">节点名称</td>
        <td>{{node.name}}</td>
    </tr>
    <tr>
        <td>状态</td>
        <td><label-on :v-is-on="node.isOn"></label-on></td>
    </tr>
    <tr>
        <td>IP地址</td>
        <td>
            <div v-if="node.ipAddresses.length > 0">
                <div>
                    <div v-for="(address, index) in node.ipAddresses" class="ui label tiny basic">
                        {{address.ip}}
                        <span class="small" v-if="address.name.length > 0">（{{address.name}}<span v-if="!address.canAccess">，不可访问</span>）</span>
                        <span class="small" v-if="address.name.length == 0 && !address.canAccess">（不可访问）</span>
                    </div>
                </div>
            </div>
            <div v-else>
                <span class="disabled">暂时还没有填写IP地址。</span>
            </div>
        </td>
    </tr>
</table>
<div class="ui divider"></div>

<h3>运行状态</h3>
<table class="ui table definition selectable">
    <tr>
        <td class="title">是否在运行</td>
        <td>
            <div  v-if="node.status.isActive">
                <span class="green">运行中</span> &nbsp;
                <!--<a href="" @click.prevent="stopNode()" v-if="!isStopping"><span>[通过SSH停止]</span></a>-->
                <span v-if="isStopping">[停止中...]</span>
            </div>
            <div v-else>
                <span class="red">已断开</span> &nbsp;
                <!--<a href="" @click.prevent="startNode()" v-if="node.isInstalled && !isStarting"><span>[通过SSH启动]</span></a>-->
                <span v-if="node.isInstalled && isStarting">[启动中...]</span>
                <a v-if="!node.isInstalled" :href="'/ns/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + node.id" ><span>去安装&gt;</span></a>
            </div>
        </td>
    </tr>
    <tbody v-show="node.status.isActive">
        <tr>
            <td>CPU用量</td>
            <td>{{node.status.cpuUsageText}} &nbsp; <span v-if="node.status.cpuPhysicalCount > 0" class="small grey">（{{node.status.cpuPhysicalCount}}核心/{{node.status.cpuLogicalCount}}线程）</span></td>
        </tr>
        <tr>
            <td>内存用量</td>
            <td>{{node.status.memUsageText}}</td>
        </tr>
        <tr>
            <td>负载</td>
            <td>{{node.status.load1m}} &nbsp; {{node.status.load5m}} &nbsp; {{node.status.load15m}} &nbsp; <tip-icon content="三个数字分别代表1分钟、5分钟、15分钟平均负载"></tip-icon></td>
        </tr>
        <tr>
            <td>版本</td>
            <td>v{{node.status.buildVersion}}
                &nbsp; <a :href="'/ns/clusters/cluster/upgradeRemote?clusterId=' + clusterId" v-if="shouldUpgrade"><span class="red">发现新版本v{{newVersion}} &raquo;</span></a>
            </td>
        </tr>
    </tbody>
</table>
<p class="comment" v-if="node.status.isActive">每隔30秒钟更新一次运行状态。</p>

<div class="ui divider"></div>
<h3>安装信息</h3>
<table class="ui table definition selectable">
    <tr>
        <td>节点ID<em>（id）</em></td>
        <td>{{node.uniqueId}}</td>
    </tr>
    <tr>
        <td>密钥<em>（secret）</em></td>
        <td>{{node.secret}}</td>
    </tr>
    <tr>
        <td class="title">安装目录</td>
        <td>
            <div v-if="node.installDir.length == 0">使用集群设置<span v-if="node.cluster != null && node.cluster.installDir.length > 0">（{{node.cluster.installDir}}）</span></div>
            <span v-else>{{node.installDir}}</span>
        </td>
    </tr>
    <tr>
        <td>是否已安装</td>
        <td>
            <span v-if="node.isInstalled" class="green">已安装</span>
            <a v-else :href="'/ns/clusters/cluster/node/install?clusterId=' + clusterId + '&nodeId=' + nodeId" class="underline" title="点击进入安装界面"><span class="red">未安装</span></a>
        </td>
    </tr>
</table>